#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int > vec;
typedef pair < int , int > pii;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e3 + 10;

bool vis[N], ins[N];
int a[N], b[N], n;
ll cur;
vec G[N];

bool dfs(int x, int p) {
	if(vis[x] || ins[x]) return true; if(cur < a[x]) return false;
	ins[x] = true; cur += b[x];
	for(auto y : G[x]) if(y ^ p) if(dfs(y, x)) return vis[x] = true, ins[x] = false, true;
	ins[x] = false; cur -= b[x]; return false;
}

bool check(int mid) {
	cur = mid; rep(i, 2, n) vis[i] = false; vis[1] = true;
	bool fl = true; 
	while(fl) {
		fl = false;
		rep(i, 1, n) if(vis[i]) for(auto s : G[i]) if(!vis[s]) if(dfs(s, i)) { fl = true; break; }
	}
	rep(i, 1, n) if(!vis[i]) return false;
	return true;
}

void solve() {
	n = in; int m = in; rep(i, 1, n) G[i].clear();
	rep(i, 2, n) a[i] = in;
	rep(i, 2, n) b[i] = in;
	rep(i, 1, m) { int u = in, v = in; G[u].pb(v); G[v].pb(u); }
	int l = 0, r = 1e9 + 7;
	while(l <= r) {
		int mid = l + r >> 1;
		if(!check(mid)) l = mid + 1;
		else r = mid - 1; 
	} printf("%d\n", l + 1); 
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    int T = in; while(T--) solve();
}
